package com.samebuilding.util;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class PhotoUtil {
	private static String sp = "/";

	private static String getDateStr() {
		Date date = new Date();
		SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
		return fmt.format(date);
	}

	public static String[] getPhotoAndThumbnailPath(String ctxPath, String dir,
			int userNo, int categoryCode) {

		String photoPath = dir + sp + userNo + sp + categoryCode + sp
				+ getDateStr() + sp + "photo" + sp;
		File file = new File(ctxPath + sp + photoPath);
		if (!file.exists()) {
			file.mkdirs();
		}
		String thumbnailPath = dir + sp + userNo + sp + categoryCode + sp
				+ getDateStr() + sp + "thumbnail" + sp;
		file = new File(ctxPath + sp + thumbnailPath);
		if (!file.exists()) {
			file.mkdirs();
		}
		return new String[] { photoPath, thumbnailPath };

	}

}
